import requests

url0 = "https://api.weixin.qq.com/sns/jscode2session"
appid = 'wxeb8df9d2df69c632'
secret = '2b9d4c78da41bb475ec886415ead4a4b'


def get_openid(jscode):
    url = url0 + "?appid=" + appid + "&secret=" + secret + "&js_code=" + jscode + "&grant_type=authorization_code"
    r = requests.get(url)
    openid = r.json()['openid']
    return openid
